package org.jeecg.modules.demo.navigation.service.impl;

import org.jeecg.modules.assist.PageAssist;
import org.jeecg.modules.demo.navigation.entity.Information;
import org.jeecg.modules.demo.navigation.mapper.InformationMapper;
import org.jeecg.modules.demo.navigation.service.IInformationService;
import org.springframework.stereotype.Service;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @Description: 信息表
 * @Author: jeecg-boot
 * @Date:   2019-09-18
 * @Version: V1.0
 */
@Service
public class InformationServiceImpl extends ServiceImpl<InformationMapper, Information> implements IInformationService {
	
	@Autowired
	private InformationMapper informationMapper;

	@Override
	public boolean updateVisitsById(String id) {
		return informationMapper.updateVisitsById(id);
	}

	@Override
	public boolean updateStateById(String id, String state) {
		return informationMapper.updateStateById(id,state);
	}

	@Override
	public List<Information> getInformationPageByType(String typeStr,Integer uPage, Integer noPage, Integer sizePage) {
		List<Information> list=null;
		try{
			PageAssist pageAssist=new PageAssist(noPage,sizePage);
			pageAssist.setPage(uPage);
			int pageNo1=pageAssist.getPageNo();
			list=informationMapper.queryInformationPageByType(typeStr,pageNo1,sizePage);
		}catch(Exception e){
			e.printStackTrace();
		}
		return list;
	}

	@Override
	public int getTypeCount(String typeStr) {
		int count = 0;
		try {
			count=informationMapper.queryTypeCount(typeStr);
		}catch (Exception e){
			e.printStackTrace();
		}
		return count;
	}

	@Override
	public List<Information> selectByMainId(String mainId) {
		return informationMapper.selectByMainId(mainId);
	}
}
